package com.hualan.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hualan.mapper.CourseSortMapper;
import com.hualan.pojo.CourseSort;
import com.hualan.pojo.PageResult;
import com.hualan.service.CourseSortService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class CourseSortServiceImpl implements CourseSortService {

    @Autowired
    private CourseSortMapper courseSortMapper;
    @Override
    public PageResult queryAllCourseSort(String categoryName, Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);
        List<CourseSort> courseSortList = courseSortMapper.queryAllCourseSort(categoryName);
        Page<CourseSort> p=(Page<CourseSort>)courseSortList;
        return new PageResult<>(p.getTotal(),p.getResult());
    }

    @Override
    public void deleteCourseSort(List<Integer> ids) {
        courseSortMapper.deleteCourseSort(ids);
    }

    @Override
    public void saveCourseSort(CourseSort courseSort) {
        courseSortMapper.saveCourseSort(courseSort);
    }

    @Override
    public void updateCourseSort(CourseSort courseSort) {
        courseSortMapper.updateCourseSort(courseSort);
    }

    @Override
    public CourseSort getCourseSortById(Integer id) {
        return courseSortMapper.getCourseSortById(id);
    }
}
